#ifndef UL_CONFIG_H
#define UL_CONFIG_H

#include <stdio.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

#define UL_NULL (0)
#define ul_inline                   static __inline
#define ul_weak                     __attribute__((weak))
#define UL_ALIGN_DOWN(size,align)	((size)&~((align)-1)) 
#include "assert.h"
#define UL_ASSERT   assert
#define UL_ALIGN_SIZE 4

/* ULIB basic data type definitions */
typedef float       ul_fp32_t;
typedef double      ul_fp64_t;
typedef int8_t      ul_int8_t;
typedef uint8_t     ul_uint8_t;
typedef int16_t     ul_int16_t;
typedef uint16_t    ul_uint16_t;
typedef int32_t     ul_int32_t;
typedef uint32_t    ul_uint32_t;
typedef size_t      ul_size_t;


typedef enum {
    UL_EOK = 0,
    UL_ERROR,
    UL_ETIMEOUT,
    UL_ENULL,
    UL_EFULL,
} ul_ecode;


#define RTTHREAD

#ifdef RTTHREAD
#include "rtthread.h"
#define ul_malloc   rt_malloc
#define ul_free     rt_free
#define ul_memcpy   rt_memcpy
#elif defined(FREERTOS)
#include "freertos.h"
#define ul_malloc   pvPortMalloc
#define ul_free     vPortFree
#else
// 默认使用标准库
#include <stdlib.h>
#include <string.h>
#define ul_malloc   malloc
#define ul_free     free
#endif  /* RTTHREAD 或 FREERTOS */

#ifdef __cplusplus
}
#endif  /* __cplusplus */

#endif
